<pre class="docs-method-signature"><code>curve.tangentAtLength(length [, opt])</code></pre>
<p>Return a line that is tangent to the curve at a point that lies <code>length</code> away from the beginning of the curve.</p>

<p>If negative <code>length</code> is provided, the algorithm starts looking from the end of the curve. If <code>length</code> is higher than curve length, a line tangent to the closest curve endpoint is returned instead.</p>

<p>The tangent line starts at the specified point. The direction from <code>start</code> to <code>end</code> is the same as the direction of the curve at the specified point.</p>

<p>If the control points of the curve all lie at the same coordinates, <code>null</code> is returned (it is impossible to determine the slope of a point). The <code>curve.isDifferentiable()</code> <a href="#g.Curve.prototype.isDifferentiable">function</a> may be used in advance to determine whether tangents can exist for a given curve.</p>

<p>The curve is first subdivided, according to <code>opt.precision</code> (refer to <code>curve.length()</code> <a href="#g.Curve.prototype.length">documentation</a> for more information about precision and curve flattening). Then, one subdivision is identified which contains the point at <code>length</code>. A binary search is then performed on that subdivision, until a curve is found whose endpoint lies within <code>opt.precision</code> away from <code>length</code>. That endpoint is used as the start of the tangent line.</p>

<p>The default value for <code>opt.precision</code> is 3; this corresponds to maximum observed error of 0.1%.</p>

<p>The <code>opt.subdivisions</code> property may be specified, directly providing an array of pre-computed curve subdivisions from which to calculate curve length. Use the <code>curve.getSubdivisions()</code> <a href="#g.Curve.prototype.getSubdivisions">function</a> to obtain an array of curve subdivisions. The <code>opt.precision</code> property is still necessary, however; it determines the precision of the point search algorithm.</p>
